Skip to content

openalexVectorComp 0.3.5: skip unchanged rows, replace re-embedded rows - #12

Merged
rkrug merged 9 commits into
mainfrom
dev
Oct 27, 2026
Merged

rkrug merged 9 commits into
mainfrom
dev

Conversation

@rkrug

@rkrug rkrug commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Merges dev into main for openalexVectorComp 0.3.5 (main is at 0.3.4). See NEWS.md.

Changes

  • Unchanged rows were always re-embedded. The lookup of existing hashes passed the label to arrow::open_dataset() as its schema argument and failed silently, so embed_corpus(delete_existing = FALSE) re-embedded everything and batch_submit_openai() resubmitted already-embedded rows as paid OpenAI batch jobs. Both now share one working helper.
  • Re-embedded rows replace the old ones. New shards are appended after the existing ones (previously batch=1 would have been overwritten), and once they are written the superseded rows are removed from older shards, so each id appears once per label and distance/score functions see no duplicates. Duplicates left by earlier versions are cleaned up on the next write.
  • Tests: offline coverage 80% → 99.6% (mocked HTTP for HF, OpenAI, TEI and the batch API).

Checks

  • devtools::test() offline: 584 passed, 0 failed (3 HF-token skips)
  • CI on dev: PR Checks green

🤖 Generated with Claude Code

rkrug and others added 9 commits October 27, 2026 16:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README hard-coded "Current development version: 0.3.0" and the
0.3.0 highlights, and installed from a local zip. It now shows live
badges (r-universe, main, dev, CI, coverage) grouped like the org
README, points to NEWS.md for changes, and installs from r-universe or
GitHub dev. CLAUDE.md: CI matrix and triggers as they are now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add offline tests (httr2 mocked responses, mocked bindings, tempdir
fixtures) for the OpenAI Batch HTTP layer, batch state/status/collect/
submit helpers, HF/OpenAI/TEI backend adapters, embed_corpus verbose and
dry-run paths, distance/score/calibration edge cases and the demo
runners. No changes under R/.

Two tests are skipped as known bugs: existing-hash loading in
embed_corpus() and .ovc_load_existing_hash() passes the label partition
as open_dataset()'s `schema`, so unchanged rows are never skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
embed_corpus() and .ovc_load_existing_hash() passed the label folder as
the `schema` argument of arrow::open_dataset(), which always errored
inside try(), so no existing hashes were loaded: every run re-embedded the
whole corpus and batch_submit_openai() resubmitted embedded rows.

- .ovc_load_existing_hash() opens model_dir/label=<label> directly and
  keeps the newest batch=<n> hash per id.
- embed_corpus() uses that helper instead of its own copy, and appends
  new shards after existing ones so skipped runs do not overwrite shards
  holding unchanged rows.
- Un-skip the two "Known bug" tests; add a test for appending changed rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a changed row is re-embedded (embed_corpus() with
delete_existing = FALSE, or batch_collect_openai()), its old row stayed in
an older batch=<n> shard, so readers saw the id twice.

- New .ovc_prune_superseded_rows(label_dir): newest shard wins; older
  shards are rewritten without superseded ids (temp file + rename), and
  emptied shard files and batch= folders are deleted. Also cleans
  duplicates left by earlier versions.
- Both writers call it only after their new shards are written.
- .ovc_load_existing_hash() keeps the newest-hash rule as a safety net.
- Tests for embed_corpus (rewrite, emptied shard removed, distances see
  each id once) and batch_collect_openai.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rkrug
rkrug merged commit 1c360bd into main Oct 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant